<?php
if (!defined('TIMESTARTPAGE')) 
{
    define('TIMESTARTPAGE', microtime(true));
}
if (substr_count($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip')) 
{
    //@ob_start("ob_gzhandler");
}
//load config
@include "../includes/config/config.php";
//create object db
include "../includes/class_mysql.php";
include "../includes/gpc_function.php";
include "includes/functions.php" ;
include "language/language.php";
include "includes/global.php";
@require "includes/permission.php";

if ($act == "logout")
{
    Logout();
}
//check module exists
if (!empty($module) && is_dir("source/" . $module) == false)
{
    $moduleDir = "module";
} else
{
    $moduleDir = $module;
}

$actFile = $act;

if($actFile=="index")
{
    $actFile = "default";
}
else if($act=='myaccount')
{
    $actFile = 'edit';
}
else
{
    $actFile = str_replace(array('add','insert'),array('edit','update'),$act);
}

$actFile = $moduleDir . "/" . $actFile;

//check action exists
if (is_file("source/" . $actFile . '.php') == false)
{
    $actFile = $moduleDir . "/default";
}
//include functions of this module if exists:
if(is_file("./source/" . $moduleDir . "/functions.php"))
{
    @include ("./source/" . $moduleDir . "/functions.php");
}


//-------------------include files------------------------------------------------------

//include processor:
include ("./source/" . $actFile . ".php");

//include toolbar of module
if($act!="login")
{
    include("includes/class_toolbar.php");
    if(is_file("./source/" . $moduleDir . "/toolbar.php"))
    {
        include("./source/" . $moduleDir . "/toolbar.php");
    }
    //include menu
    include ("includes/functions_menu.php");
}

//-------- Out Put HTML ---------
if($popup!==true && $AjaxFrame!==true)
{
    include ("./templates/header.tpl");
}
include ("./templates/" . $actFile . ".tpl");

if($popup!==true && $AjaxFrame!==true)
{
    include ("./templates/footer.tpl");
}
?>